﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace QLHXNK.DataAccess
{
    class Import_NoteData
    {
        #region --------------------------------------------Thêm, Xoá, Sửa-----------------------------------------
        //Thêm:
        public static int Insert(String import_note_code, String import_note_date, String exchange_rate, String remark)
        {
            String strSQL = String.Format("INSERT INTO Import_Note (import_note_code, import_note_date, exchange_rate, remark) VALUES ('{0}', '{1}', {2}, '{3}')", import_note_code.Replace("'", "''"), import_note_date.Replace("'", "''"), (exchange_rate.Replace("'", "''") == "") ? "NULL" : exchange_rate.Replace("'", "''"), remark.Replace("'", "''"));
            return MyDataTransfer.executeNonQueryCommand(strSQL);
        }

        //Xóa:
        public static int Delete(int ID)
        {
            String strSQL = String.Format("DELETE FROM import_note WHERE ID = {0}", ID);
            return MyDataTransfer.executeNonQueryCommand(strSQL);
        }

        //Sửa:
        public static int Update(int ID, String import_note_code, String import_note_date, String exchange_rate, String remark)
        {
            String strSQL = String.Format("UPDATE  Import_Note SET import_note_code = '{0}', import_note_date = '{1}', exchange_rate = {2}, remark = '{3}' WHERE ID = {4}", import_note_code.Replace("'", "''"), import_note_date.Replace("'", "''"), (exchange_rate.Replace("'", "''") == "") ? "NULL" : exchange_rate.Replace("'", "''"), remark.Replace("'", "''"), ID);

            return MyDataTransfer.executeNonQueryCommand(strSQL);
        }
        public static int Update1(int ID, String import_note_code, String import_note_date, String exchange_rate)
        {
            String strSQL = String.Format("UPDATE  Import_Note SET import_note_code = '{0}', import_note_date = '{1}', exchange_rate = {2} WHERE ID = {3}", import_note_code.Replace("'", "''"), import_note_date.Replace("'", "''"), (exchange_rate.Replace("'", "''") == "") ? "NULL" : exchange_rate.Replace("'", "''"), ID);

            return MyDataTransfer.executeNonQueryCommand(strSQL);
        }
        #endregion

        #region -----------------------------------------Lấy danh sách----------------------------------
        public static DataTable getImport_NoteList(String strSQL)
        {
            if (strSQL == "")
                strSQL = "SELECT * FROM Import_Note";
            return MyDataTransfer.executeQueryCommand(strSQL);
        }
        #endregion
    }
}
